package demo2;

public class Computer implements IUSB{
    @Override
    public void openDevice() {
        System.out.println("打开电脑");
    }
    //使用电脑
    public void useDevice(IUSB iusb) {
        iusb.openDevice();
        if(iusb instanceof Mouse) {
            Mouse mouse = (Mouse)iusb;
            mouse.clickMouse();
        }else {
            KeyBoard keyboard = (KeyBoard)iusb;
            keyboard .inPut();
        }
        iusb.closeDevice();
    }
    @Override
    public void closeDevice() {
        System.out.println("关闭电脑");
    }
}
